/**
 * 
 */
package com.lb.store.berkeleydb.perf;

import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.KeyField;
import com.sleepycat.persist.model.Persistent;
import com.sleepycat.persist.model.PrimaryKey;

/**
 * @author LionBule
 * 2011-5-10 ����02:58:05
 */
public class DPLEntity {

}

@Persistent
class CompositeKey {

    @KeyField(1)
    int f0 = 0;
    @KeyField(2)
    String f1 = "The quick brown fox jumps over the lazy dog.";

    CompositeKey() { } // for bindings

    CompositeKey(int f0) {
        this.f0 = f0;
    }

    CompositeKey(int f0, String f1) {
        this.f0 = f0;
        this.f1 = f1;
    }

    @Override
    public String toString() {
        return "CompositeKey: (" + f0 + "," + f1 + ")";
    }
}

@Entity
class BasicEntity {

    @PrimaryKey
    CompositeKey key;

    protected long id = 0;
    protected String one = "one";
    protected double two = .2d;
    protected String three = "three";
    Address address = new Address();

    BasicEntity() { }

    BasicEntity(int i) {
        this.key = new CompositeKey(i);
    }

    public void modify() {
        id++;
        one += "1";
        two = id;
        three += "3";
        address = new Address("Shenzhen", "Guangdong, China", 500001);
    }

    @Override
    public String toString() {
        return "BasicEntity: (" + key + "," + id + "," + one + "," +
            two + "," + three + ", " + address + ")";
    }
}

@Persistent
class Address {

    private String city = "Boston";
    private String state = "Massachusetts";
    private int zip = 10001;

    Address() { }

    Address(String city, String state, int zip) {
        this.city = city;
        this.state = state;
        this.zip = zip;
    }

    @Override
    public String toString() {
        return "Address: (" + city + "," + state + "," + zip + ")";
    }
}